<?php
namespace Home\Controller;
use Think\Controller;
use Think\Model;

class CommonController extends Controller {
    public function _initialize(){
        //查询系统配置信息.获取最低安装费，安装费返点临界值，安装费返点
        $configInfo = M('system_config')->getField('config_name,config_value');

        //判断用户是否处于维护中
        if($configInfo['system_maintenance'] == 0){
            $this->display('system_maintenance');
            exit;
        }

        //获取该用户购物车中单品个数
        if(session('user_id') != null){
            $cart_num = M('goods_cart gc')
                ->join('__GOODS__ gs on gs.good_id=gc.goods_id')
                ->where('user_id='.session('user_id'))
                ->count();
        }
        $cart_num = $cart_num ? $cart_num:0;

        $this->assign('cart_num',$cart_num);
        $this->assign('configInfo',$configInfo);
    }
}